package griffin.website;

import griffin.logic.UserLogic;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;

public class Splash extends Activity {
	UserLogic userLogic = new UserLogic(this);
	
	private Thread mSplashThread;   
	private static final String TAG = "[splash]";
	@Override 
	public void onCreate(Bundle savedInstanceState) {  
		Log.d(TAG, "[onCreate...] ");			
		super.onCreate(savedInstanceState);  
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        
		//prepareLogin
		userLogic.prepareLogin();

		// Splash screen view  
		setContentView(R.layout.splash);  
		final Splash sPlashScreen = this;     
		// The thread to wait for splash screen events  
		mSplashThread =  new Thread(){  
			@Override 
			public void run(){  
				try {  
					synchronized(this){  
						// Wait given period of time or exit on touch  
						wait(1000);  
					}
				} 
				catch(InterruptedException ex){                      
				}  
				finish();  
				// Run next activity  
				Intent intent = new Intent(); 
				intent.setClass(sPlashScreen, TabBarFramework.class);  
				startActivity(intent);  
				stop();                      
			}  
		};  
		mSplashThread.start();  
	}  
	/** 
	 * Processes splash screen touch events  

	 */ 
	@Override 
	public boolean onTouchEvent(MotionEvent evt)  
	{  
		if(evt.getAction() == MotionEvent.ACTION_DOWN)  
		{  
			synchronized(mSplashThread){  
				mSplashThread.notifyAll();  
			}  
		}  
		return true;  
	}  
} 
